<!DOCTYPE html>
<html style="background:rgba(0,0,0,0)">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <meta name="format-detection" content="address=no" />
    <meta name="format-detection" content="date=no" />
    <title>选择生日</title>
    <link href="../../css/aui.css" rel="stylesheet" type="text/css">
    <link href="../../css/api.css" rel="stylesheet" type="text/css">
    <link href="../../mui/mui.min.css" rel="stylesheet" type="text/css">
    <link href="../../mui/mui.picker.css" rel="stylesheet" type="text/css">
    <link href="../../mui/mui.poppicker.css" rel="stylesheet" type="text/css">
    <style>
        html,
        body {
            background: rgba(0, 0, 0, 0);
            margin: 0;
            height: 100vh;
        }

        .mui-poppicker-header {
            background-color: #fff;
            border: 0;
            position: relative;
            z-index: 999;
            height: 2.5rem;
            padding: 0 0.85rem;
            border-radius: 0.2rem 0.2rem 0 0;
        }

        .mui-poppicker-body {
            height: 9.1rem;
        }

        .mui-poppicker-header .mui-btn {
            border: 0;
            color: #222224;
            font-size: 0.7rem;
            padding: 0;
            line-height: 2.5rem;
            margin: 0;
        }

        .mui-btn.mui-poppicker-btn-cancel {
            background: none;
            width: auto;
            height: 2.5rem;
            padding: 0;
            line-height: 2.5rem;
            margin: 0;
        }

        .mui-btn.mui-poppicker-btn-cancel:active {
            background: none;
            border: none;
            color: #222224;
        }

        .mui-btn.mui-poppicker-btn-ok {
            color: rgba(0, 202, 207, 1);
            font-size: 0.7rem;
            background: none;
            width: auto;
            height: 2.5rem;
            padding: 0;
            line-height: 2.5rem;
            margin: 0;
        }
        
        .mui-btn.mui-poppicker-btn-ok:active {
            background: none;
            border: none;
            color: rgba(0, 202, 207, 1);
        }

        .mui-poppicker {
            border: 0;
            box-shadow: none;
        }

        .mui-poppicker-body {
            position: relative;
            border-top: 0.5px solid #eaeaea;
        }
        /*.mui-poppicker-body:before{
        content: "";
        position: absolute;
        top:0;
        left:0;
        height: 1px;
        width: 100%;
        background: #eaeaea;
        transform: scaleY(0.5);
        -webkit-transform: scaleY(0.5);
        transform-origin: 0 0;
        -webkit-transform-origin: 0 0;
    }*/

        .mui-pciker-rule-ft {
            border-top: none;
            border-bottom: none;
        }

        .mui-pciker-list li {
            color: #B5B6BA;
            font-size: 0.75rem;
        }

        .mui-backdrop {
            display: none;
        }

        .mui-pciker-list li.highlight {
            font-size: 0.9rem;
            color: #222224;
        }

        #layerDiv {
            position: absolute;
            top: 0;
            z-index: 9;
            left: 0;
            background: rgba(0, 0, 0, 0.5);
            width: 100%;
            height: 100%;
        }
    </style>
</head>

<body style="background:rgba(0,0,0,0)">
    <div id="layerDiv" tapmode onclick="fnCloseLayer()"></div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../mui/mui.min.js"></script>
<script type="text/javascript" src="../../mui/mui.bottom-picker.js"></script>
<script type="text/javascript" src="../../mui/mui.poppicker.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-data.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript">
    var birthday;
    var $S;
    var USER;
    var activeIndex = [0, 0, 0];
    var picker;
    apiready = function() {
        $S = SERVICE();
        USER = USER();
        if (api.pageParam.type == 'start' || api.pageParam.type == 'end') {
            if (api.pageParam.time && api.pageParam.time != '') {
                var _time = api.pageParam.time.split("-");
                for (var i = 0; i < arrData.length; i++) {
                    if (arrData[i].name.indexOf(_time[0]) > -1) {
                        activeIndex[0] = i;
                        activeIndex[1] = _time[1] - 1;
                        activeIndex[2] = _time[2] - 1;
                    }
                }
            }
        } else {
            if (api.pageParam.birthday) {
                var birth = api.pageParam.birthday.split("-");
                for (var i = 0; i < arrData.length; i++) {
                    if (arrData[i].name.indexOf(birth[0]) > -1) {
                        activeIndex[0] = i;
                        activeIndex[1] = birth[1] - 1;
                        activeIndex[2] = birth[2] - 1;
                    }
                }
            } else {
                for (var i = 0; i < arrData.length; i++) {
                    if (arrData[i].name.indexOf(1990) > -1) {
                        activeIndex[0] = i;
                    }
                }
            }
        }
        fnJudge()
    };

    function fnJudge() {
        if (arrData && arrData.length > 0) {
            fnOpenMui(); //打开生日选择器模块
        } else {
            setTimeout(function() {
                fnJudge()
            }, "100")
        }
    }

    function fnOpenMui() {
        mui.init();
        picker = new mui.PopPicker({
            layer: 3,
            buttons: ['取消', '完成']
        });
        picker.setData(arrData);
        for (var i = 0; i < activeIndex.length; i++) {
            picker.pickers[i].setSelectedIndex(activeIndex[i]);
        }
        picker.show(function(items) {
            if (items && items.length > 0) {
                var dateBirth = parseInt(items[0].name) + "-" + formatNumber(parseInt(items[1].name)) + "-" + formatNumber(parseInt(items[2].name));
                if (api.pageParam.type == 'start' || api.pageParam.type == 'end') {
                    api.execScript({
                        name: 'mine/consultant_authenticate_win',
                        frameName: 'mine/consultant_authenticate',
                        script: 'fnSetTime("' + api.pageParam.type + '","' + api.pageParam.index + '","' + dateBirth + '");'
                    });
                } else {
                    api.execScript({
                        name: api.pageParam.winName || 'mine/personal_info_win',
                        frameName: api.pageParam.frmName || 'mine/personal_info',
                        script: 'fnUpdateInfor("birthday","' + dateBirth + '");'
                    });
                }

            }
            fnCloseLayer()
        });
    }

    function fnCloseLayer() {
        api.closeFrame();
    }
</script>

</html>
